package com.hsylient.javase.chapter09;

import org.junit.Test;

import java.util.List;
import java.util.stream.Collectors;

public class StreamPageTest {


    private static final List<String> list = List.of("A", "B", "C", "D", "E", "F", "G", "H", "I");

    @Test
    public void testStreamPage() {
        int pageNum = 2;
        int pageSize = 4;

        // 记得设置pageTotal
        List<String> page = list.stream()
                .skip((pageNum - 1) * pageSize)
                .limit(pageSize)
                .collect(Collectors.toList());
        System.out.println(page);
    }
}
